// 自动点击人机验证，自动点击播放下一节
setInterval(function () {
  var btn = $(".layui-layer-dialog > .layui-layer-btn > .layui-layer-btn0");
  if (btn.length) {
    btn.click();
    console.log('点击"继续学习"');
  } else {
    console.log('未找到 "继续学习" 按钮');
  }
}, 5000);

function studyEndedHandle() {
  var curLearning = $(".learning.current");
  if (curLearning.length) {
    console.log(curLearning.find("a")[0].innerText + "播放完了");
  }
  setTimeout(function () {
    var nextLi = curLearning.next();
    if (nextLi.length) {
      var next = nextLi.find("a");
      if (next.length) {
        var name = next[0].innerText;
        next.click();
        console.log("点击 播放下一节：" + name);
        console.log("等待网络请求, 5秒后点击 播放");
        setTimeout(function () {
          console.log("点击 播放按钮");
          foot.player.playOrPause();
          foot.player.addListener("ended", studyEndedHandle);
        }, 5000);
      }
    } else {
      console.log("没有找到下一节，你可能已经全部学完了");
    }
  }, 1000);
}

foot.player.addListener("ended", studyEndedHandle);
